package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.controller.CxBase;
import com.ruoyi.system.domain.backend.SafetyExaminationInfoDate;
import com.ruoyi.system.domain.front.SafetyExaminationFrontInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SafetyExaminationInfoMapper;
import com.ruoyi.system.domain.SafetyExaminationInfo;
import com.ruoyi.system.service.ISafetyExaminationInfoService;

/**
 * 考试信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-04-07
 */
@Service
public class SafetyExaminationInfoServiceImpl extends CxBase implements ISafetyExaminationInfoService
{
    @Autowired
    private SafetyExaminationInfoMapper safetyExaminationInfoMapper;

    /**
     * 查询考试信息
     * 
     * @param safetyExaminationId 考试信息ID
     * @return 考试信息
     */
    @Override
    public SafetyExaminationInfoDate selectSafetyExaminationInfoById(String safetyExaminationId)
    {
        SafetyExaminationInfoDate safetyExaminationInfoDate = new SafetyExaminationInfoDate();
        SafetyExaminationInfo safetyExaminationInfo = safetyExaminationInfoMapper.selectSafetyExaminationInfoById(safetyExaminationId);
        safetyExaminationInfoDate.setSafetyExaminationId(safetyExaminationInfo.getSafetyExaminationId());
        safetyExaminationInfoDate.setSafetyExaminationName(safetyExaminationInfo.getSafetyExaminationName());
        safetyExaminationInfoDate.setSafetyExaminationType(safetyExaminationInfo.getSafetyExaminationType());
        safetyExaminationInfoDate.setStartTime(StampToDate(Long.valueOf(safetyExaminationInfo.getStartTime())));
        safetyExaminationInfoDate.setFinishTime(StampToDate(Long.valueOf(safetyExaminationInfo.getFinishTime())));
        safetyExaminationInfoDate.setSetDate(StampToString(Long.valueOf(safetyExaminationInfo.getSetDate())));
        safetyExaminationInfoDate.setSetId(safetyExaminationInfo.getSetId());
        return safetyExaminationInfoDate;
    }

    /**
     * 查询考试信息列表
     * 
     * @param safetyExaminationInfo 考试信息
     * @return 考试信息
     */
    @Override
    public List<SafetyExaminationInfo> selectSafetyExaminationInfoList(SafetyExaminationInfo safetyExaminationInfo)
    {
        startPage();
        List<SafetyExaminationInfo> safetyExaminationInfos = safetyExaminationInfoMapper.selectSafetyExaminationInfoList(safetyExaminationInfo);
        for(SafetyExaminationInfo safetyExaminationInfo1 : safetyExaminationInfos){
            safetyExaminationInfo1.setStartTime(StampToString(Long.valueOf(safetyExaminationInfo1.getStartTime())));
            safetyExaminationInfo1.setFinishTime(StampToString(Long.valueOf(safetyExaminationInfo1.getFinishTime())));
            safetyExaminationInfo1.setSetDate(StampToString(Long.valueOf(safetyExaminationInfo1.getSetDate())));
        }
        return safetyExaminationInfos;
    }

    /**
     * 新增考试信息
     * 
     * @param safetyExaminationInfo 考试信息
     * @return 结果
     */
    @Override
    public int insertSafetyExaminationInfo(SafetyExaminationInfoDate safetyExaminationInfo)
    {
        SafetyExaminationInfo safetyExaminationInfo1 = new SafetyExaminationInfo();
        if(!checkNull(safetyExaminationInfo.getSafetyExaminationName())&&!checkNull(safetyExaminationInfo.getSafetyExaminationType())&&!checkNull(safetyExaminationInfo.getSetId())
        &&!checkNull(safetyExaminationInfo.getStartTime())&&!checkNull(safetyExaminationInfo.getFinishTime()))
        {
            safetyExaminationInfo1.setSafetyExaminationId(getIdStamp().toString());
            safetyExaminationInfo1.setSafetyExaminationName(safetyExaminationInfo.getSafetyExaminationName());
            safetyExaminationInfo1.setSafetyExaminationType(safetyExaminationInfo.getSafetyExaminationType());
            safetyExaminationInfo1.setStartTime(dateToStamp(safetyExaminationInfo.getStartTime()).toString());
            safetyExaminationInfo1.setFinishTime(dateToStamp(safetyExaminationInfo.getFinishTime()).toString());
            safetyExaminationInfo1.setSetDate(getStamp().toString());
            safetyExaminationInfo1.setSetId(safetyExaminationInfo.getSetId());
            return safetyExaminationInfoMapper.insertSafetyExaminationInfo(safetyExaminationInfo1);
        }
        return 0;
    }

    /**
     * 修改考试信息
     * 
     * @param safetyExaminationInfo 考试信息
     * @return 结果
     */
    @Override
    public int updateSafetyExaminationInfo(SafetyExaminationInfoDate safetyExaminationInfo)
    {
        SafetyExaminationInfo safetyExaminationInfo1 = new SafetyExaminationInfo();
        if(!checkNull(safetyExaminationInfo.getSafetyExaminationId())&&!checkNull(safetyExaminationInfo.getSetId()))
        {
            safetyExaminationInfo1.setSafetyExaminationId(safetyExaminationInfo.getSafetyExaminationId());
            if(!checkNull((safetyExaminationInfo.getSafetyExaminationName()))){
                safetyExaminationInfo1.setSafetyExaminationName(safetyExaminationInfo.getSafetyExaminationName());
            }
            if(!checkNull((safetyExaminationInfo.getSafetyExaminationType()))){
                safetyExaminationInfo1.setSafetyExaminationType(safetyExaminationInfo.getSafetyExaminationType());
            }
            if(!checkNull((safetyExaminationInfo.getStartTime()))){
                safetyExaminationInfo1.setStartTime(dateToStamp(safetyExaminationInfo.getStartTime()).toString());
            }
            if(!checkNull((safetyExaminationInfo.getFinishTime()))){
                safetyExaminationInfo1.setFinishTime(dateToStamp(safetyExaminationInfo.getFinishTime()).toString());
            }
            safetyExaminationInfo1.setSetDate(getStamp().toString());
            safetyExaminationInfo1.setSetId(safetyExaminationInfo.getSetId());
            return safetyExaminationInfoMapper.updateSafetyExaminationInfo(safetyExaminationInfo1);
        }
        return 0;
    }

    /**
     * 批量删除考试信息
     * 
     * @param safetyExaminationIds 需要删除的考试信息ID
     * @return 结果
     */
    @Override
    public int deleteSafetyExaminationInfoByIds(String[] safetyExaminationIds)
    {
        return safetyExaminationInfoMapper.deleteSafetyExaminationInfoByIds(safetyExaminationIds);
    }

    /**
     * 删除考试信息信息
     * 
     * @param safetyExaminationId 考试信息ID
     * @return 结果
     */
    @Override
    public int deleteSafetyExaminationInfoById(String safetyExaminationId)
    {
        return safetyExaminationInfoMapper.deleteSafetyExaminationInfoById(safetyExaminationId);
    }
}
